using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Windows.Forms;

namespace CSShell
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (_IsMultiInstanceRun())
            {
                MessageBox.Show("Instance existed", "Warning:", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1); 
            }
            else
            {
                Application.Run(new Shell());
            }
        }

        static bool _IsMultiInstanceRun()
        {
            try
            {
                string _name = Process.GetCurrentProcess().ProcessName;
                Process[] _process = Process.GetProcessesByName(_name);
                if (_process.Length > 1)
                {
                    return true;
                }
            }
            catch (Exception e)
            {
                string _err = e.Message;
            }

            return false;
        }
    }
}